import 'package:flutter/foundation.dart';
import 'package:ibooks/utils/utils.dart';

class Book {
  int id;
  String name;
  String path;
  String type;
  int process;

  Book({@required this.name, @required this.path, this.type, this.process});

  Map<String, dynamic> toJson() {
    Map<String, dynamic> map = new Map();
    map["id"] = id;
    map["name"] = name;
    map["path"] = path;
    map["type"] = type;
    map["process"] = process;
    return map;
  }

  static Book fromJson(Map<String, dynamic> map) {
    Book book = new Book();
    book.id = map["id"];
    book.name = map["name"];
    book.path = map["path"];
    book.type = map["type"]??FileType.TEXT;
    book.process = map["process"] ?? 0;
    return book;
  }
}
